package com.masterclient.app.modules.firstpager.fragments.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.firstpager.AllSpecailBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/14
*/
public class SpecialListPresenter extends SpecialListContract.Presenter{

    @Override
    public void getSpecailList(String page, String page_size, String type) {

        Observable<AllSpecailBean> observable = RetrofitUtil.getInstance().getSpecailList(page+"-"+page_size+".html",type);
        Disposable disposable = toSubscribe(observable, new Consumer<AllSpecailBean>() {
            @Override
            public void accept(@NonNull AllSpecailBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showSpecailList(bean.getData());
                }
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}